<?php
/**
 * Template Name: Projects Display
 * Description: A Page Template that showcases Sticky Posts, Asides, and Blog Posts
 *
 * The showcase template in Twenty Eleven consists of a featured posts section using sticky posts,
 * another recent posts area (with the latest post shown in full and the rest as a list)
 * and a left sidebar holding aside posts.
 *
 * We are creating two queries to fetch the proper posts and a custom widget for the sidebar.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

// Enqueue showcase script for the slider
wp_enqueue_script( 'twentyeleven-showcase', get_template_directory_uri() . '/js/showcase.js', array( 'jquery' ), '2011-04-28' );

get_header(); ?>

<html>
<div class="projectsearch">
	<div id="pagetitle">Projects</div>
	<div class="sortbar">
		<a href="http://students.washington.edu/andreybr/wordpress/?page_id=75&sort=new">Newest</a> |
		<a href="http://students.washington.edu/andreybr/wordpress/?page_id=75&sort=updated">Just Updated</a> |
		<a href="http://students.washington.edu/andreybr/wordpress/?page_id=75&sort=ratings">Highest Rated</a> |
		<a href="http://students.washington.edu/andreybr/wordpress/?page_id=75&sort=comments">Most Comments</a>
	</div>
	<?php if($_GET['sort'] == 'new') 
		query_posts('posts_per_page=5'); 
	elseif($_GET['sort'] == 'comments') 
		query_posts('orderby=comment_count&posts_per_page=5');
	else
		query_posts('posts_per_page=10'); 
	?>
	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

	<div class="projectsearchbox">
		<div id="projectsearchheader">
			<div id="projectsearchtitle">
				<a href="http://students.washington.edu/andreybr/wordpress/?p=<?php echo get_the_ID() ?>">
				<?php the_title() ?>
				</a>
			</div>
			<div id="projectsearchauthor">
				<a href="http://students.washington.edu/andreybr/wordpress/?page_id=208&user=<?php the_author_meta('ID'); ?>">
					<?php the_author() ?> 
				</a> 
			</div>
		</div>
		<img id="projectsearchimage" src="http://chandra.harvard.edu/photo/2013/ngc6240/ngc6240_lg.jpg">
		<div id="projectsearchmeta">
			<div id="projectsearchmeta1">
				<?php 
					$comments_count = wp_count_comments(get_the_ID());
					echo $comments_count->approved . " Comments";
				?>
			</div>
			<div id="projectsearchmeta1">9.5</div>
			<div id="projectsearchmeta1">University of Washington</div>	
			<div id="projectsearchmeta1">
				<?php 
					echo " Uploaded " . the_time('m/d/y');
				?>
			</div>
			<div id="projectsearchbar"></div>
			<div id="projectsearchdescription">	
				<?php the_content() ?>
			</div>
		</div>
	</div>

	<?php endwhile; else: ?>
	<?php endif; ?>
</div>
<html>

<?php get_footer(); ?>